<?php
/**
 * Created by PhpStorm.
 * User: win7
 * Date: 2018/6/6 0006
 * Time: 9:19
 */

namespace Wx\Controller;


use Think\Controller;

class FarmingSpellgroupController extends Controller
{
    public function index(){
        header("Access-Control-Allow-Origin: *");//同源策略 跨域请求 头设置

        $id = $_POST['id'];
        $jsonp = $_GET['showDate'];//get接收jsonp自动生成的函数名
        $id = explode(',',$id);//分割字符串
        $arr = array();
        foreach($id as $k => $v){
            $spellgroup = M('shop_spellgroup')->where("id = {$v}")->field('id,u_id,h_imgs,title,price,actual_num,actual_price')->find();//商品信息
            foreach($spellgroup as $sk => $sv){
                if ($sk == 'u_id'){
                    $spellgroup['member'] = getMember($sv,'nickname,avatar');//商品发布人信息
                }
                if ($sk == 'h_imgs'){
                    $spellgroup['h_imgs'] = isMorePic($sv);//商品图片处理
                }
            }//end foreach
            $arr[] = $spellgroup;
        }

        echo $jsonp.json_encode($arr); //jsonp函数名包裹json数据
    }
}//end class